﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AgentList.aspx.cs" Inherits="_Default"
    ValidateRequest="false" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <!--#include virtual="include/Head.ascx"-->
    <script type='text/javascript' src="assets/js/Country.js"></script>
    <script type="text/javascript" language="javascript">
        function doDelete(strID, strAgentName) {
            if (confirm('Bạn có thực sự muốn xóa Agent: ' + strAgentName + '?')) {
                var vnpage = getUrlVars()['page_number'];
                if (vnpage)
                    window.location.href = "AgentList.aspx?action=delete&AgentID=" + strID + "&page_number=" + vnpage;
                else
                    window.location.href = "AgentList.aspx?action=delete&AgentID=" + strID;
            }
        }
        function openAgentDetail(strID, strAgentName) {
            var url = "AgentDetail.aspx?AgentID=" + strID;
            window.open(url, 'AgentDetail', 'width=600,height=400,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0');
        }
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }
        $().ready(function () {
            //$('#txtCountry').focus().autocomplete(country, { matchContains: true });
            jQuery("#txtCountry").blur(function () {
                var vaCountry = jQuery("#hidCountryCode").val();
                jQuery.ajax({
                    type: "POST",
                    url: "AjaxFile/LoadCityByCountry.ashx?country=" + vaCountry,
                    success: function (msg) {
                        var arrSource = msg.split(",");
                        $('#txtCity').autocomplete(arrSource);
                    }
                });
            }).blur();

        });
        function OnCountrySelected(source, eventArgs) {
            var hdnValueID = "<%= hidCountryCode.ClientID %>";
            document.getElementById(hdnValueID).value = eventArgs.get_value();
            $("#txtCountry").focus();
        }
    </script>
</head>
<body>
    <div id="body-wrapper">
        <div id="header">
            <!--#include virtual="include/top.ascx"-->
        </div>
        <div id="main-content1">
            <h2>AGENT LIST</h2>
            <div class="clear">
            </div>
            <div class="content-box">
                <form id="frmCarrContact" runat="server" autocomplete="off">
                    <%if (nPermissions >= 3)
                      {%>
                    <div class="content-box-header">
                        <h3 style="cursor: s-resize;">Agent List Add [Edit]
                        </h3>
                        <div class="clear">
                        </div>
                    </div>
                    <table class="adminedit" style="width: 100%;">
                        <tr>
                            <%if (nPermissions >= 7)
                              {%>
                            <th align="left" width="120px">Quốc gia
                            </th>
                            <th align="left" width="120px">City / Cảng
                            </th>
                            <th align="left" width="200px">Tên đại lý
                            </th>
                            <%} %>
                            <th align="left">ADD/TEL/MOBIL/PIC/SOCIALNET
                            </th>
                            <th align="left" width="150px">Take Note
                            </th>
                            <th align="left" width="100px">Display(*)
                            </th>
                        </tr>
                        <tr>
                            <%if (nPermissions >= 7)
                              {%>
                            <td>
                                <%--<asp:TextBox class="cls" ID="txtCountry" runat="server" Width="90%" TabIndex="2"></asp:TextBox>--%>
                                <asp:ToolkitScriptManager ID="ScriptManager1" runat="server">
                                </asp:ToolkitScriptManager>
                                <asp:TextBox class="cls" ID="txtCountry" runat="server" Width="90px"></asp:TextBox>
                                <asp:HiddenField ID="hidCountryCode" runat="server"></asp:HiddenField>
                                <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" ServiceMethod="CountryAutoCompleteAjaxRequest"
                                    ServicePath="Webservices/AutoComplete.asmx" MinimumPrefixLength="2" CompletionInterval="100"
                                    EnableCaching="true" CompletionSetCount="10" TargetControlID="txtCountry"
                                    FirstRowSelected="true" CompletionListCssClass="completionList" CompletionListItemCssClass="listItem"
                                    CompletionListHighlightedItemCssClass="itemHighlighted" DelimiterCharacters=","
                                    OnClientItemSelected="OnCountrySelected">
                                </asp:AutoCompleteExtender>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtCity" runat="server" Width="90%" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtAgent" runat="server" Width="90%" TabIndex="2"></asp:TextBox>
                            </td>
                            <%} %>
                            <td>
                                <asp:TextBox class="cls" ID="txtAddress" runat="server" Width="90%" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:TextBox class="cls" ID="txtDescription" runat="server" Width="82%" TabIndex="2"></asp:TextBox>
                            </td>
                            <td>
                                <asp:CheckBox class="cls" ID="cbDisplay" runat="server" Width="82%" TabIndex="2"></asp:CheckBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6">
                                <%if (nPermissions >= 3)
                                  {%>
                                <p>
                                    (*) If the checkbox is not checked, then users (with 'view' permission) will not
                                have the right to see this agent
                                </p>
                                <%} %>
                                <asp:Label ID="ErrMessage" runat="server" CssClass="error"></asp:Label>
                            </td>
                        </tr>
                    </table>
                    <table class="paramlist admintable" width="100%">
                        <tr>
                            <td colspan="4">
                                <asp:Button class="button" ID="btnSave" runat="server" TabIndex="2" Text="Save" OnClick="btnSave_Click" />
                            </td>
                        </tr>
                    </table>
                    <%} %>
                    <div class="content-box-header">
                        <h3 style="cursor: s-resize;">Agent List</h3>
                        <div class="clear">
                        </div>
                    </div>
                    <table class="adminedit" style="width: 500px;">
                        <tr>
                            <th align="center" style="font-weight: bold;">Coutry
                            </th>
                            <th align="center" style="font-weight: bold;">City
                            </th>
                            <th align="center" style="font-weight: bold; display: none;">Agent
                            </th>
                            <%if (nPermissions >= 3)
                              {%>
                            <th align="center" style="font-weight: bold;">Display
                            </th>
                            <%} %>
                        </tr>
                        <tr>
                            <td align="left">
                                <asp:DropDownList class="cls" ID="drCountrySearch" runat="server" Width="200px" TabIndex="16"
                                    AutoPostBack="True" OnSelectedIndexChanged="txtCountrySearch_SelectedIndexChanged">
                                </asp:DropDownList>
                            </td>
                            <td align="left">
                                <asp:DropDownList class="cls" ID="drCitySearch" runat="server" Width="200px" TabIndex="17"
                                    AutoPostBack="true" OnTextChanged="btnSearch_Click">
                                </asp:DropDownList>
                            </td>
                            <td align="left" style="display: none;">
                                <asp:TextBox class="cls" ID="txtAgentSearch" runat="server" Width="200px" TabIndex="17"></asp:TextBox>
                            </td>
                            <td align="left">
                                <asp:DropDownList class="cls" ID="ddDisplay" runat="server" Width="200px" TabIndex="17"
                                    AutoPostBack="true" OnTextChanged="btnSearch_Click">
                                    <asp:ListItem Text="" Value=""></asp:ListItem>
                                    <asp:ListItem Text="Yes" Value="1"></asp:ListItem>
                                    <asp:ListItem Text="No" Value="0"></asp:ListItem>
                                </asp:DropDownList>
                            </td>
                            <td style="display: none;">
                                <asp:Button class="button" ID="btnSearch" runat="server" TabIndex="13" Text="Serch"
                                    OnClick="btnSearch_Click" />
                            </td>
                        </tr>
                    </table>
                    <fieldset>
                        <asp:Repeater ID="rptData" runat="server">
                            <ItemTemplate>
                                <tr onmouseover="this.style.background='#dbf0c9'" onmouseout="this.style.background='#ffffff'">
                                    <td align="center">
                                        <%# DataBinder.Eval(Container.DataItem, "Index")%>
                                    </td>
                                    <td style="text-align: left; width: 80px;">
                                        <%# DataBinder.Eval(Container.DataItem, "Country")%>
                                    </td>
                                    <td style="text-align: left; width: 80px;">
                                        <%# DataBinder.Eval(Container.DataItem, "City") %>
                                    </td>
                                    <td style="text-align: left; width: 150px;">
                                        <%# DataBinder.Eval(Container.DataItem, "Agent") %>
                                    </td>
                                    <td style="text-align: left;">
                                        <%# DataBinder.Eval(Container.DataItem, "Address")%>
                                    </td>
                                    <!--td style="text-align:center;width:100px;">
                                        <%# DataBinder.Eval(Container.DataItem, "Mobile")%>
                                    </td-->
                                    <td style="text-align: center; width: 100px;">
                                        <%# DataBinder.Eval(Container.DataItem, "Description")%>
                                    </td>
                                    <td style="text-align: center; width: 50px;">
                                        <%# DataBinder.Eval(Container.DataItem, "LastUpdate")%>
                                    </td>
                                    <%if (nPermissions >= 3)
                                      {%>
                                    <td align="center">
                                        <%# DataBinder.Eval(Container.DataItem, "Action") %>
                                    </td>
                                    <%} %>
                                </tr>
                            </ItemTemplate>
                            <HeaderTemplate>
                                <table cellspacing="0" cellpadding="0" width="100%" border="0" class="adminlist">
                                    <thead>
                                        <tr style="background: #CCC;">
                                            <!--th align="center" width="50px">
                                                STT</th -->
                                            <th align="center" width="30px">Index
                                            </th>
                                            <th align="center">Quốc gia
                                            </th>
                                            <th align="center">City / Cảng
                                            </th>
                                            <th align="center">Tên đại lý
                                            </th>
                                            <th align="center">ADD/TEL/MOBIL/PIC/SOCIALNET
                                            </th>
                                            <th align="center">Take Note
                                            </th>
                                            <!--th align="center">
                                                Social net</th-->
                                            <th align="center">Cập nhật
                                            </th>
                                            <%if (nPermissions >= 3)
                                              {%>
                                            <th align="center" width="125px">Action
                                            </th>
                                            <%} %>
                                        </tr>
                                    </thead>
                            </HeaderTemplate>
                            <FooterTemplate>
                                </TABLE>
                            </FooterTemplate>
                        </asp:Repeater>
                    </fieldset>
                    <div class="clear">
                    </div>
                    <div id="footer">
                        <%=strPager%>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <%--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
    </script>

    <script type="text/javascript">
_uacct = "UA-2623402-1";
urchinTracker();
    </script>--%>
</body>
</html>
